package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.pojo.Analysis;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AnalysisMapper extends BaseMapper<Analysis> {
    //累计用户
    @Select("select sum(num_registered) from tb_analysis")
    Long cumulativeUsers();


    //条件查询
    @Select("SELECT * FROM tb_analysis WHERE record_date =#{format} ")
    Analysis findOneByTime(@Param("format")String format);

    @Select("SELECT SUM(num_active) FROM tb_analysis\n" +
        "where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= record_date")
    Long findActivePassWeek();

    //    //过去30天活跃用户数
    @Select("SELECT SUM(num_active) FROM tb_analysis where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= record_date")
    Long findActivePassMonth();
}

